import 'package:dio/dio.dart';
import 'package:flutter_learn_vi/src/bean/bean_train.dart';
import 'package:flutter_learn_vi/src/net/dio_utils.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/1/27.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
/// 评价相关的接口请求
class EvaluateModel {
  CancelToken _signCancelToken;

  ///获取用户的打卡记录
  Future<List<SignRecoderBean>> getUserTrainSignRecoderList(
      {int trainId}) async {
    if (_signCancelToken != null && !_signCancelToken.isCancelled) {
      _signCancelToken.cancel();
    }
    _signCancelToken = new CancelToken();
    List<SignRecoderBean> courseList = [];
    //答题数据
    ResponseInfo statisRresponseInfo = await DioUtils.instance.postRequest(
        url: HttpHelper.trainSignRecoderUrl,
        cancelTag: _signCancelToken,
        jsonMap: {
          "trainId": trainId,
          "pageIndex": 1,
        });
    if (statisRresponseInfo.success) {
      List list = statisRresponseInfo.data;
      if (list != null) {
        list.forEach((element) {
          courseList.add(SignRecoderBean.fromMap(element));
        });
      }
    }
    return courseList;
  }
}
